package com.atguigu.day02;

import org.apache.flink.util.MathUtils;

public class Example9 {
    public static void main(String[] args) {
        String key = "b";
        // 第一步：获取key的hashCode
        int hashCode = key.hashCode();
        // 第二步：根据key的hashCode计算出murmurHash值
        int murmurHash = MathUtils.murmurHash(hashCode);
        // 第三步：计算key要被路由到的reduce的并行子任务的索引
        int maxParallelism = 128;
        int parallelismOfReduce = 4;
        int idx = (murmurHash % maxParallelism) * parallelismOfReduce / maxParallelism;
        System.out.println("idx: " + idx);
    }
}
